<%@ page import="com.wuming.house.security.SecurityHander" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/3/20
  Time: 18:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>管理标签</title>
    <link rel="stylesheet" href="${allServerPath}static/layui/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${allServerPath}static/layui/css/public.css" media="all"/>
</head>
<body style="background-color: #f0f2f5;" class="childrenBody">
<div class="layui-fluid wuli-main">
    <div class="layui-row">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>编辑标签</legend>
        </fieldset>
        <form class="layui-form">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">标签名称</label>

                    <div class="layui-input-inline">
                        <select id="tagId" name="tagId" lay-filter="tagId">
                            <option value=""></option>
                        </select>
                        <input type="hidden" id="tagName" name="tagName" value=""/>
                    </div>
                </div>
            </div>
            <input type="hidden" id="houseType" name="houseType" value="2">
        </form>
        <div class="layui-row wuli-button">
            <button class="layui-btn layui-btn-normal" name="btnSave">保存</button>
        </div>
    </div>
</div>
<script type="text/javascript" src="${allServerPath}static/layui/layui/layui.js"></script>
<script src="${allServerPath}static/js/jquery-2.1.4.min.js"></script>
<script>
    layui.use(['layer', 'form', 'jquery'], function () {
        var form = layui.form
            , layer = layui.layer
            , $ = layui.$;


        //推荐人
        $.ajax({
            type: 'post',
            url: '${allServerPath}web/tag/all.htmls',
            dataType: 'JSON',
            success: function (obj) {
                if (obj.success) {
                    $.each(obj.data, function (index, item) {
                        var s = "<option value='" + item.id + "'>" + item.tagName + "</option>";
                        $("#tagId").append(s);
                    })
                    form.render();
                }
            }
        });


        form.on('select(tagId)', function (data) {
            var tagName = $(data.elem).find("option:selected").text();
            $("input[name='tagName']").val(tagName);
        });

        $("button[name='btnSave']").on('click', function () {
            $.ajax({
                type: "post",
                data: {
                    houseId: '${houseId}',
                    houseType: $("#houseType").val(),
                    tagId: $("#tagId").val(),
                    tagName: $("#tagName").val()
                },
                url: '${allServerPath}web/housetag/save.htmls',
                success: function (obj) {
                    if (obj.success) {
                        layer.msg("保存成功");
                    }
                }
            });
        });
    });

</script>
</body>
</html>
